package com.example.bijiabao.mapper;

import com.example.bijiabao.entity.book;
import com.example.bijiabao.entity.user;
import com.example.bijiabao.entity.bookPlatform;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface spbookMapper {

    //连接book,platform,通过ISBN查询
    @Select("SELECT book.*,platform.* from book join platform on book.pfId=platform.pfId WHERE ISBN=#{ISBN} ORDER BY bookPrice asc")
    List<bookPlatform> findAllBookByISBN(@Param("ISBN") String ISBN);

    //详情页最便宜商品
    @Select("SELECT book.*,platform.* from book join platform on book.pfId=platform.pfId WHERE ISBN=#{ISBN} order by bookPrice asc limit 1")
    bookPlatform findBookByISBN(@Param("ISBN") String ISBN);

    //相同作者的书
    @Select("SELECT * from book WHERE writer=#{writer}")
    List<book> findBookByWrietr(@Param("writer") String writer);

    //
    @Select("SELECT * from user WHERE userName=#{userName}")
    user selectbyUserName(@Param("userName") String userName);
}
